import { _decorator, Component, director, Label } from 'cc';
import DataManager from '../../manager/data.manager';
const { ccclass, property } = _decorator;

@ccclass('LoadScene')
export class LoadScene extends Component {

	private lbl_state: Label;

	protected onLoad(){
		this.init();
	}

	protected start(){
		this.adaptUI();
		DataManager.oncePoint('GameInitStart', 'GameInitFinish');
		director.loadScene('main');
	}

	private init(){
		DataManager.init();
		this.lbl_state = this.node.getChildByName('state').getComponent(Label);
		this.lbl_state.string = 'Apple is not a sponsor nor is involved in any way\nwith these contests and sweepstakes';
	}

	private adaptUI(){
		mtec.cc.adaptBackgroundNode(this.node.getChildByName('background'));
		let va_state = new mtec.cc.VecAssist(this.lbl_state.node);
		va_state.getPosition('center', 'bottom');
		va_state.vec.add3f(0, 61, 0);
		this.lbl_state.node.setPosition(va_state.vec);
	}
}

